Skip to content

[@mantine/core] Add openOnFocus prop to Combobox based components (#5893)#8623

Merged
rtivital merged 1 commit intomantinedev:masterfrom
harry-ignite:fix/5893-open-select-on-focus
Jan 20, 2026
Merged

[@mantine/core] Add openOnFocus prop to Combobox based components (#5893)#8623
rtivital merged 1 commit intomantinedev:masterfrom
harry-ignite:fix/5893-open-select-on-focus

Conversation

@harry-ignite
Copy link
Copy Markdown
Contributor

No description provided.

…antinedev#5893)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new openOnFocus prop to several Combobox-based inputs to control whether their dropdown opens automatically when the input receives focus.

Changes:

  • Introduces openOnFocus?: boolean to TagsInput, Select, MultiSelect, and Autocomplete
  • Sets default behavior to open on focus (true) and gates combobox.openDropdown() behind the new flag
  • Updates focus handlers to respect openOnFocus

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
packages/@mantine/core/src/components/TagsInput/TagsInput.tsx Adds openOnFocus prop/default and conditions dropdown opening on input focus.
packages/@mantine/core/src/components/Select/Select.tsx Adds openOnFocus prop/default and conditions dropdown opening on focus for searchable Select.
packages/@mantine/core/src/components/MultiSelect/MultiSelect.tsx Adds openOnFocus prop/default and conditions dropdown opening on focus for searchable MultiSelect.
packages/@mantine/core/src/components/Autocomplete/Autocomplete.tsx Adds openOnFocus prop (defaulted via destructuring) and conditions dropdown opening on focus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/** Clear search value when item is selected */
clearSearchOnChange?: boolean;

/** If set, the dropdown opens when the input receives focus @default `true` */
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openOnFocus is only honored when searchable is true (see onFocus handler below). Please update this prop description to reflect that it does not open the dropdown on focus in non-searchable mode.

Suggested change
/** If set, the dropdown opens when the input receives focus @default `true` */
/** If set and `searchable` is `true`, the dropdown opens when the input receives focus @default `true` */

Copilot uses AI. Check for mistakes.
Comment on lines 463 to 466
onFocus={(event) => {
onFocus?.(event);
combobox.openDropdown();
openOnFocus && combobox.openDropdown();
}}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test coverage for the new openOnFocus behavior: verify that by default focusing the input opens the dropdown, and that setting openOnFocus={false} prevents opening on focus (while other opening mechanisms still work).

Copilot uses AI. Check for mistakes.
Comment on lines 346 to 349
onFocus={(event) => {
!!searchable && combobox.openDropdown();
openOnFocus && !!searchable && combobox.openDropdown();
onFocus?.(event);
}}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for openOnFocus: for a searchable Select, focusing the input should open the dropdown by default, and should not open when openOnFocus={false} is set.

Copilot uses AI. Check for mistakes.
Comment on lines 437 to 440
onFocus={(event) => {
onFocus?.(event);
searchable && combobox.openDropdown();
openOnFocus && searchable && combobox.openDropdown();
}}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for openOnFocus: for a searchable MultiSelect, focusing the input should open the dropdown by default, and should not open when openOnFocus={false} is set.

Copilot uses AI. Check for mistakes.
Comment on lines 220 to 223
onFocus={(event) => {
combobox.openDropdown();
openOnFocus && combobox.openDropdown();
onFocus?.(event);
}}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for the new openOnFocus prop: by default focusing the input should open the dropdown, and openOnFocus={false} should prevent opening on focus.

Copilot uses AI. Check for mistakes.
/** If set, the highlighted option is selected when the input loses focus @default `false` */
autoSelectOnBlur?: boolean;

/** If set, the dropdown opens when the input receives focus @default `true` */
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openOnFocus docs are a bit misleading here: the dropdown only opens on focus when searchable is enabled (see onFocus handler below). Consider updating the prop description to mention that it affects focus behavior only for searchable Selects.

Suggested change
/** If set, the dropdown opens when the input receives focus @default `true` */
/** If set, the dropdown opens when the input receives focus, but only when `searchable` is enabled @default `true` */

Copilot uses AI. Check for mistakes.
@rtivital rtivital merged commit 93dda54 into mantinedev:master Jan 20, 2026
7 checks passed
@rtivital
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants